#include <iostream>
#include <stack>
using namespace std;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    while (k--)
    {
        int next = 1;
        bool can = true;
        stack<int> st;
        int input, cnt = 0;
        while (cnt < n)
        {
            cin >> input;
            st.push(input);
            cnt++;
            if (st.size() == m + 1 && st.top() != next)
            {
                can = false;
                break;
            }
            while (!st.empty() && st.top() == next)
            {
                st.pop();
                next++;
            }
        }
        while (cnt < n)
        {
            cin >> input;
            cnt++;
        }
        if (can && st.empty())
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    return 0;
}